﻿#region  == Copyright == 
// =====================================================================
//  $CUSTOMER$ - 2013
//  Projet     : Solution Cmd Helper - Solution Cmd Helper
//  Fichier    : Logger.cs (26/06/2013 09:51)
//  
//  Copyright (C) Microsoft Corporation.  All rights reserved.
// =====================================================================
#endregion

namespace Solution.Cmd.Helper
{
    #region  == Using == 
    using System;
    using System.IO;

    #endregion

    public class Logger
    {
        private readonly string LogFilePath = string.Empty;
        private const string Format = "{0} : {1}{2}";

        /// <summary>
        /// Initializes a new instance of the <see cref="Logger"/> class.
        /// </summary>
        /// <param name="logFilePath">The log file path.</param>
        public Logger(string logFilePath)
        {
            Console.WriteLine("Log path : {0}", logFilePath);
            this.LogFilePath = logFilePath;
        }

        #region Write
        /// <summary>
        /// Log message to file
        /// </summary>
        /// <param name="message">The message.</param>
        public void Write(string message)
        {
            if (string.IsNullOrEmpty(this.LogFilePath))
            {
                return;
            }
            File.AppendAllText(this.LogFilePath, string.Format(Format, DateTime.Now, message, Environment.NewLine));
        }
        #endregion
    }
}